<?php
/**
 * Created by PhpStorm.
 * User: My
 * Date: 2018/9/3
 * Time: 15:51
 */

namespace App\Repositories;

use App\Http\Helper\BeanHelper;
use App\Models\TestingPart;

class TestingPartRepository extends Repository
{
    /**
     * 根据测评ID和维度获取部分题目记录
     * @param $tid
     * @param $dimension
     * @return mixed
     */
    public function getOneByTidAndDimension($tid, $dimension) {
        return BeanHelper::convertStdClsToArr(
            TestingPart::where([
                'tid' => $tid,
                'dimension' => $dimension
            ])->first()
        );
    }

    /**
     * 获取当前测评的部分的最大值
     * @param $tid
     * @return mixed
     */
    public function getMaxDimensionByTid($tid) {
        return TestingPart::where([
            'tid' => $tid,
        ])->max('dimension');
    }

    /**
     * 根据测评ID获取所有的维度信息
     * @param $tid
     * @return mixed
     */
    public function getListByTid($tid) {
        return BeanHelper::convertStdClsToArr(
            TestingPart::where('tid', $tid)->get()
        );
    }

    public function model() {
        return app(TestingPart::class);
    }

    public function tag() {
        // TODO: Implement tag() method.
    }
}